<?php 
	include "config.php";
	include DOC_ROOT."templates/header.php";
	include DOC_ROOT."templates/left.php";
?>
<?php
$conInfo= array("UID"=>"SA","PWD"=>"/Manhtoanpc45/","Database"=>"shop");
		$con=sqlsrv_connect("(local)",$conInfo);
if( $con === false ) {
     die( print_r( sqlsrv_errors(), true));
}
$page = 1;
		if(isset($_GET['page'])){
			$page = $_GET['page'];	
		}		
		$row_per_page = 10;
		$start = ($page-1)* $row_per_page;
		$end = $page * $row_per_page;
?>
					<div id="main-content">
						<div id="slider">
							<ul class="rslides">
  								<li><img src="images/sliders/1.jpg" alt="" /></li>
  								<li><img src="images/sliders/2.jpg" alt="" /></li>
  								<li><img src="images/sliders/3.jpg" alt="" /></li>
  								<li><img src="images/sliders/4.jpg" alt="" /></li>
							</ul>
							<script>
  								$(function () {
    							$(".rslides").responsiveSlides({	
    								auto: true,
    								random: true,
    								maxheight: "400",
    								maxwidth: "660",
    							});
  								});
							</script>
						</div><!-- END slider -->
						<div id="product-list">
							<div class="block-title head">
								<strong><span>Product list</span></strong>
							</div>
                            
                            <?php
						$stmt= sqlsrv_query($con,"SELECT * FROM(SELECT row_number() over(order by product_id desc) as row,
						p.* FROM product p
			) as a WHERE row between $start AND $end");
		$stmt1 = sqlsrv_query($con,"SELECT count(*) from product");
		sqlsrv_fetch($stmt1);
		$tong = sqlsrv_get_field($stmt1,0);
		$sotrang = ceil($tong/$row_per_page);
		while(sqlsrv_fetch($stmt)){
			$id = sqlsrv_get_field($stmt,0);
	?>
    

							<ol class="row 1">
								<li class="item" style="width: 33%;">
									<h5><a href="#" title="mtxt"> <?=sqlsrv_get_field($stmt,2)?></a></h5>
									<p class="product-image">
										<a href="#" title="BOLD 9000 OEM"><img alt="BOLD 9000 OEM" src="images/products/Toshiba_Satellit.jpg" class="product-image item" /></a>
									</p>
									<div class="ratings">
										<div class="rating-box">
											
										</div>
										<p class="rating-links">
											<a href="#">1 Review (s)</a>
											<span class="separator"> | </span>
											<a href="#">Add Your Review</a>
										</p>
									</div><!-- END ratings -->
									<div class="price-form clearfix">
										<div class="price-box">
											<span class="regular-price">
												<span class="price"><?=sqlsrv_get_field($stmt,6)?></span>
											</span>
										</div><!-- END price-box -->
										<button class="add-cart"><span>Add to Cart</span></button>
									</div><!-- END price -->
								</li>
								<?php 
								}
								?>
                              
							</ol>
                          
						</div><!-- END product-list --> 		
                     </div><!-- END main-content -->   
                     <div >
						<?php
							for($i=1;$i<$sotrang+1;$i++){
						?>
    							<a href="<?=URL_ROOT?>index1.php?page=<?=$i?>">[<?=$i?>]</a>
    					<?php		
								}
						?></div>
				</div><!-- END wrap-content -->
			</div><!-- END content -->
<?php 
 	include DOC_ROOT."templates/footer.php";
 ?>

